#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>
int* sortedSquares(int* nums, int numsSize, int* returnSize) {
    int* ret = (int*)malloc(sizeof(int) * numsSize);
    int left = 0;
    int right = numsSize - 1;
    int index = numsSize - 1;
    while (left <= right)
    {
        int a = nums[left] * nums[left];
        int b = nums[right] * nums[right];
        if (a > b)
        {
            ret[index--] = a;
            left++;
        }
        else
        {
            ret[index--] = b;
            right--;
        }
    }
    *returnSize = numsSize;
    return ret;
}
int main()
{
    int a = 0;
    int nums[] = { -89,-12,0,-1,2,4.7,4324 };
    int* ret = sortedSquares(nums, sizeof(nums)/sizeof(int), &a);
    for (int i = 0; i < a; i++)
    {
        printf("%d ", ret[i]);
    }
}